package org.oslims.client.view.impl;

import org.oslims.client.uicomponents.ConfirmationBox;
import org.oslims.client.uicomponents.editbox.AssignLabResponsibleBox;
import org.oslims.client.uicomponents.editbox.EditReportsBox;
import org.oslims.client.uicomponents.editbox.EditRequestBox;
import org.oslims.client.view.RequestEditorView;
import org.oslims.domain.Request;

import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.user.cellview.client.CellTable;
import com.google.gwt.user.cellview.client.SimplePager;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DockLayoutPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.view.client.MultiSelectionModel;

public class RequestEditorViewImpl extends BaseViewImpl implements RequestEditorView {

	final Button addRequestButton = new Button("Add Request");
	final Button releaseRequestsButton = new Button("Release selected Requests");
	final Button closeRequestsButton = new Button("Close selected Requests");
	final ConfirmationBox confirmationBox = new ConfirmationBox();

	Integer defaultPageSize = 15;
	final CellTable<Request> requestTable = new CellTable<Request>();
	final SimplePager<Request> pager = new SimplePager<Request>(requestTable);
	final MultiSelectionModel<Request> selectionModel = new MultiSelectionModel<Request>();

	EditRequestBox editRequestBox = new EditRequestBox();
	AssignLabResponsibleBox assignLabResponsibleBox = new AssignLabResponsibleBox();
	EditReportsBox editReportsBox = new EditReportsBox();

	public RequestEditorViewImpl() {

		DockLayoutPanel content = new DockLayoutPanel(Unit.PCT);

		content.setStyleName("mainContent");
		VerticalPanel headerPanel = new VerticalPanel();

		Label header = new Label("Request Management");
		header.setStyleName("viewHeader");

		headerPanel.add(header);
		content.addNorth(headerPanel, 5);

		VerticalPanel footerPanel = new VerticalPanel();
		footerPanel.add(pager);

		HorizontalPanel buttonLine = new HorizontalPanel();
		buttonLine.add(addRequestButton);
		buttonLine.add(releaseRequestsButton);
		buttonLine.add(closeRequestsButton);
		footerPanel.add(buttonLine);

		content.addSouth(footerPanel, 10);

		ScrollPanel tablePanel = new ScrollPanel();
		tablePanel.add(requestTable);

		content.add(tablePanel);

		initWidget(content);
	}

	@Override
	public HasClickHandlers getAddRequestButton() {
		return addRequestButton;
	}

	@Override
	public EditRequestBox getEditRequestBox() {
		return editRequestBox;
	}

	@Override
	public HasClickHandlers getReleaseRequestsButton() {
		return releaseRequestsButton;
	}

	@Override
	public AssignLabResponsibleBox getAssignLabResponsibleBox() {
		return assignLabResponsibleBox;
	}

	@Override
	public HasClickHandlers getCloseRequestsButton() {
		return closeRequestsButton;
	}

	@Override
	public ConfirmationBox getConfirmationBox() {
		return confirmationBox;
	}

	@Override
	public Integer getDefaultPageSize() {
		return defaultPageSize;
	}

	@Override
	public CellTable<Request> getTable() {
		return requestTable;
	}

	@Override
	public SimplePager<Request> getPager() {
		return pager;
	}

	@Override
	public MultiSelectionModel<Request> getSelectionModel() {
		return selectionModel;
	}

	@Override
	public EditReportsBox getEditReportsBox() {
		return editReportsBox;
	}

}
